package org.groupg.filetodb.model;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;

import javax.sql.DataSource;
import java.io.File;
import java.util.Properties;

/**
 * 数据加载任务配置
 */
public class Task {
    /**
     * 数据加载任务的ID
     */
    private String taskID;
    /**
     * 数据加载任务的名称
     */
    private String taskName;
    /**
     * 数据加载任务的说明
     */
    private String taskDescription;
    /**
     * 数据加载任务使用的数据目录
     */
    private File taskFileDir;
    /**
     * 数据加载任务使用的数据库连接配置 可能为空
     */
    private Properties dbProperties;
    /**
     * 数据加载任务使用的数据库连接池
     */
    private DataSource dataSource;

    @Override
    public String toString() {
        return new ToStringBuilder(this)
                .append("taskID", taskID)
                .append("taskName", taskName)
                .append("taskDescription", taskDescription)
                .append("taskFileDir", taskFileDir)
                .append("dbProperties", dbProperties)
                .append("dataSource", dataSource)
                .toString();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;

        if (o == null || getClass() != o.getClass()) return false;

        Task task = (Task) o;

        return new EqualsBuilder().append(getTaskID(), task.getTaskID()).append(getTaskName(), task.getTaskName()).append(getTaskDescription(), task.getTaskDescription()).append(getTaskFileDir(), task.getTaskFileDir()).append(getDbProperties(), task.getDbProperties()).append(getDataSource(), task.getDataSource()).isEquals();
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder(17, 37).append(getTaskID()).append(getTaskName()).append(getTaskDescription()).append(getTaskFileDir()).append(getDbProperties()).append(getDataSource()).toHashCode();
    }

    public String getTaskID() {
        return taskID;
    }

    public void setTaskID(String taskID) {
        this.taskID = taskID;
    }

    public String getTaskName() {
        return taskName;
    }

    public void setTaskName(String taskName) {
        this.taskName = taskName;
    }

    public String getTaskDescription() {
        return taskDescription;
    }

    public void setTaskDescription(String taskDescription) {
        this.taskDescription = taskDescription;
    }

    public File getTaskFileDir() {
        return taskFileDir;
    }

    public void setTaskFileDir(File taskFileDir) {
        this.taskFileDir = taskFileDir;
    }

    public Properties getDbProperties() {
        return dbProperties;
    }

    public void setDbProperties(Properties dbProperties) {
        this.dbProperties = dbProperties;
    }

    public DataSource getDataSource() {
        return dataSource;
    }

    public void setDataSource(DataSource dataSource) {
        this.dataSource = dataSource;
    }


}
